<?
include('../scaffold/tag.php');
include('../controller/handler.php');

include('../module/var.inc.php');

session_start();

$hd = new Handler();
$base_url = $hd->getBaseURL();

if($_POST!=NULL && $hd->getPassword()==sha1($_SESSION['password'])) {
	$hd->openDB();
	$hd->reset($_POST);
	$hd->closeDB();
	$hd->writeLog("[RESET] ".strftime("%c")." database resetted by ".$hd->getUsername()." ID=".
		$_SERVER['REMOTE_ADDR']);
	$feedback = "Tutti i dati selezionati sono stati cancellati con successo.";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
	<? include('../module/head.inc.php'); ?>
	<meta name="robots" content="noindex, nofollow"/>
	<script src="<?echo $base_url;?>js/editor.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<div id="content">
<?include('../module/header.inc.php');?>

<?if($hd->getPassword()==sha1($_SESSION['password'])) {?>

<div class="form">
	<div class="upper_bar_main"><div class="upper_bar_round"></div></div>
	<div class="body_main_left">
	<div class="body_main_right">
	<div class="body_main">
	<form action="reset" id="reset_form" method="post" accept-charset="utf-8" onsubmit="return confirmReset(this);;">
		<h2>Reset dati</h2>
		<div id="reset_box">
			<input type="checkbox" name="content" value="true" /> Cancella articoli<br />
			<input type="checkbox" name="comment" value="true" /> Cancella commenti<br />
			<input type="checkbox" name="tag" value="true" /> Cancella argomenti (e tutti i riferimenti agli articoli)<br />
			<input type="checkbox" name="people" value="true" /> Cancella persone<br />
			<input type="checkbox" name="editorial" value="true" /> Cancella editoriali<br />
			<input type="checkbox" name="link" value="true" /> Cancella collegamenti<br />
			<input type="checkbox" name="uploads" value="true" /> Elimina tutti i file caricati<br />
			<input type="checkbox" name="preferences" value="true" /> Ripristina le preferenze originali<br />
			<input type="checkbox" name="log" value="true" /> Svuota il log di sistema<br />
			<input type="checkbox" name="counter" value="true" /> Reset contatore (<?echo $hd->getCounter()?> visite)
			<p><input type="checkbox" name="all" value="true" onclick="toggleCheckbox(this, 'reset_form')" /> 
				<span>Seleziona tutti</span></p>
		</div>
		<p><input type="submit" value="Conferma &rarr;"></p>
	</form>
	<?if($feedback) {?><p id="feedback" class="highline"><?echo $feedback;?></p> <?}?>
	<p class="small admin_action">
		<a href="<?echo $base_url;?>panel">&larr; Pannello di amministrazione</a> |
		<a href="<?echo $base_url;?>panel/preferences">Modifica preferenze</a>
	</p>
	</div></div></div>
	<div class="lower_bar_main"><div class="lower_bar_round"></div></div>
</div>

<?}?>

<? include('../module/footer.inc.php'); ?>
</div>
</body>
</html>
